<template>
  <div class="engineeringProject">
    <TitleColumn name="工程现状" isColumn />
    <div class="content">
      <ul class="channelList">
        <li class="listItem">
          <h3>总干渠</h3>
          <p><strong>1</strong>条</p>
        </li>
        <li class="listItem">
          <h3>分干渠</h3>
          <p><strong>24</strong>条</p>
        </li>
        <li class="listItem">
          <h3>支渠</h3>
          <p><strong>34</strong>条</p>
        </li>
      </ul>
      <div class="overview">
        <ul class="list">
          <li class="listItem" :class="state.className[0]">
            <h3 :data-text="32"></h3>
            <p>防渗工程(km)</p>
          </li>
          <li class="listItem" :class="state.className[1]">
            <h3 :data-text="65"></h3>
            <p>灌排泵站(个)</p>
          </li>
          <li class="listItem" :class="state.className[2]">
            <h3 :data-text="86"></h3>
            <p>排涝工程(km)</p>
          </li>
          <li class="listItem" :class="state.className[3]">
            <h3 :data-text="132"></h3>
            <p>防汛工程(km)</p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref, reactive, onMounted, onUnmounted } from 'vue';
  import TitleColumn from '@/components/TitleColumn';

  defineOptions({ name: 'EngineeringProject' });

  const intervalId = ref(null);
  const state = reactive({
    className: ['center', 'left', 'top', 'right'],
  });

  // 定义一个函数用于移动数组的第一个元素到末尾
  function moveFirstElementToEnd() {
    const arr = state.className;
    let firstElement = arr.shift();
    arr.push(firstElement);
  }

  onMounted(() => {
    intervalId.value = setInterval(moveFirstElementToEnd, 3000);
  });

  onUnmounted(() => {
    if (intervalId.value) {
      clearInterval(intervalId.value);
    }
  });
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .engineeringProject {
    width: 50%;
    .content {
      width: 100%;
      height: calc(100% - 42px);
      background: #02123433;
      backdrop-filter: blur(10px);
      .channelList {
        width: 96%;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 24px;
        li.listItem {
          width: 30%;
          height: 50px;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          background: url(./images/channel_bg.png) no-repeat;
          background-size: 100% 100%;
          backdrop-filter: blur(10px);
          h3 {
            font-size: 14px;
            color: #fff;
          }
          p {
            font-size: 14px;
            color: #fff;
            padding-top: 6px;
            line-height: 14px;
            strong {
              font-size: 16px;
              margin-right: 2px;
              transform: scaleY(1.1);
            }
          }
        }
      }
      .overview {
        width: 100%;
        height: 180px;
        background: url(./images/bg.png) no-repeat;
        background-size: 100% 100%;
        position: relative;
        top: 10px;
        ul.list {
          width: 100%;
          height: 100%;
          li.listItem {
            width: 100px;
            height: 78px;
            background: url(./images/base_bg.png) no-repeat;
            background-size: contain;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            position: absolute;
            z-index: 100;
            transition: all 0.3s linear;
            h3 {
              color: #fff;
              width: 100%;
              height: 44px;
              position: relative;
              font-size: 28px;
              font-weight: bold;
              font-style: italic;
              color: transparent;
              margin-top: -14px;
              &::before {
                content: attr(data-text);
                width: 100%;
                position: absolute;
                z-index: 100;
                padding-right: 10px;
                background: linear-gradient(180deg, #FFFFFF 40%, #06B7FD 110%);
                -webkit-background-clip: text;
                color: transparent;
                display: flex;
                align-items: center;
                justify-content: center;
              }
              &::after {
                content: attr(data-text);
                width: 100%;
                position: absolute;
                z-index: 0;
                text-shadow: 0px 2px 6px rgba(0, 0, 0, 0.6);
                display: flex;
                align-items: center;
                justify-content: center;
              }
            }
            p {
              color: #fff;
              font-size: 12px;
              font-weight: bold;
            }
          }
        }
        .center {
          top: 96px;
          left: 50%;
          opacity: 1;
          transform: translate(-50%, 0%) scale(1, 1);
        }
        .left {
          top: 40px;
          right: 10px;
          opacity: 0.7;
          transform: translate(0%, 0%) scale(0.8, 0.8);
        }
        .top {
          top: 0px;
          left: 50%;
          opacity: 0.7;
          transform: translate(-50%, 0%) scale(0.8, 0.8);
        }
        .right {
          top: 40px;
          left: -10px;
          opacity: 0.7;
          transform: translate(0%, 0%) scale(0.8, 0.8);
        }
      }
    }
  }
</style>
